package com.guigu.gulisearch.controller;

import com.guigu.gulicommon.entity.pojo.res.Res;
import com.guigu.gulicommon.entity.vo.es.SkuEsModel;
import com.guigu.gulisearch.service.ProductEsService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * es保存控制器
 *
 * @author 陈俊杰
 * @version 1.0
 * @since 2024/8/25 22:12
 */
@RestController
@RequestMapping("/es/save")
@Log4j2
@Validated
public class EsSaveController {
    @Autowired
    private ProductEsService productEsService;

    /**
     * 上架商品到ES
     *
     * @param skuEsModels 商品信息集合
     * @return 上架结果
     */
    @PostMapping("/product")
    public Res<SkuEsModel> productStatusUp(@RequestBody List<SkuEsModel> skuEsModels) {
        log.info("上架商品入参：{}", skuEsModels);
        return productEsService.saveProduct(skuEsModels);
    }
}
